package com.aaa.demo112.demo1;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @Description:
 * @author:LiWei
 * @date:2022年11月02日9:51
 */
public class Test {
    public static void main(String[] args) {

        ExecutorService executorService= Executors.newFixedThreadPool(5);

        for (int i = 0; i <10; i++) {
            final int a =i;
            executorService.submit(new Runnable() {
                @Override
                public void run() {
                    System.out.println(Thread.currentThread().getName()+"-------"+a);
                }
            });
        }
        executorService.shutdown();

        boolean shutdown=executorService.isShutdown();
        System.out.println("shutdown = " + shutdown);
        //判断线程池是否终止
        boolean b=executorService.isTerminated();
        System.out.println("b = " + b);
    }
}
